package javaproject;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;

public class DBDriver2 {

	public void prints(String strSql){
		try{
			
			ResultSet rs = DBFactory.getDBDriverInstance().query(strSql);
			rs.beforeFirst();
			ResultSetMetaData rsmd = rs.getMetaData();
			int colCount = rsmd.getColumnCount();
			while (rs != null&&rs.next()){
				for (int i = 1;i<colCount;i++){
					System.out.print("\t"+rsmd.getColumnLabel(i)+"-"
							+rs.getObject(rsmd.getColumnLabel(i)));
				}
				System.out.println();
			}
			if(rs!=null){
				rs.close();
			}
		}catch (Exception e) {
			// TODO: handle exception
			System.out.println("查询语句出错");
			e.printStackTrace();
		}
	}
}
